<template>
  <div class="lg_loginwrap" id="loginwrap" style="min-height:422px">
    <div class="lg_loginbox lg_ercode" id="lg_loginbox" tabindex="0" style="outline: 0px; top: 10px; margin-top: 40px;" aria-label="旅行账号登录，点击tab切换聚焦位置" aria-modal="true">
      <h2 class="lg_loginbox_title" id="logintitle">扫码登录</h2>
      <div class="login-code" id="changeScanLogin"> <a title="返回账号登录" id="scanLogin" logintype="normal" @click="changeShowNum(1)">账号登录<i class="icon-computer"></i></a> </div>
      <div class="form_wrap" id="scanloginview" style="">
        <div class="qrcode" ref="qrCodeUrl"></div>
      </div>
      <div class="nologin" id="nologin" style="display: none;"> <a href="javascript:;" id="btn_nologin">不登录，直接预订<i>&gt;</i></a> </div> <input type="hidden" id="sliderResult">
    </div>
  </div>
</template>

<script>
import QRCode from 'qrcodejs2'
export default {
  name: 'LoginCode',
  methods: {
    changeShowNum(num) {
      this.$store.dispatch('changeLoginShowNum', num)
    },
    creatQrCode() {
      var qrcode = new QRCode(this.$refs.qrCodeUrl, {
        text: '二维码是展示用的，不具备登录功能', // 需要转换为二维码的内容
        width: 100,
        height: 100,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
    }
  },
  mounted() {
    this.creatQrCode()
  }
}
</script>

<style lang="scss" scoped>
.qrcode {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
h1,
h2,
h3,
h4,
h5,
input {
  font-weight: 400;
  font-family: 'Microsoft YaHei', SimSun, Tahoma, Verdana, Arial, sans-serif;
}
.lg_loginwrap {
  position: relative;
  float: right;
  width: 380px;
  min-height: 540px;
  margin-right: -40px;
  .lg_loginbox {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    background: #fff;
    padding: 30px 30px 20px;
    min-height: 370px;
    border-radius: 4px;
    -webkit-box-shadow: 0 1px 6px rgb(0 0 0 / 10%);
    box-shadow: 0 1px 6px rgb(0 0 0 / 10%);
    .lg_loginbox_title {
      position: absolute;
      padding-bottom: 16px;
      font-size: 18px;
      color: #111;
      line-height: 1;
      font-family: PingFangSC-Medium, 'Microsoft YaHei', SimSun, Tahoma, Verdana, Arial, sans-serif;
      left: 50%;
      transform: translateX(-50%);
      top: 25%;
    }
  }
  .login-code {
    position: absolute;
    top: 10px;
    right: -32px;
    background: #3882e5;
    -webkit-box-shadow: 0 1px 6px 0 rgb(0 0 0 / 10%);
    box-shadow: 0 1px 6px 0 rgb(0 0 0 / 10%);
    a {
      font-size: 13px;
      color: #fff;
      line-height: 16px;
      padding: 9px;
      width: 14px;
      height: 86px;
      display: block;
    }
    .icon-computer {
      display: inline-block;
      vertical-align: middle;
      background: url('../assets/images/un_login_20170818.png') no-repeat;
      width: 13px;
      height: 13px;
      background-position: -20px -60px;
    }
  }
  .lg_loginbox.lg_ercode {
    .er_scan_wrap {
      margin-top: 24px;
      height: 180px;
      vertical-align: bottom;
      &.er_code {
        position: relative;
        img {
          margin-top: 30px;
          &#qrcode_img {
            position: relative;
            left: 80px;
          }
        }
        .er_void {
          position: absolute;
          width: 150px;
          height: 150px;
          left: 50%;
          margin-left: -75px;
          top: 30px;
          bottom: 0;
          background: #666;
          background: rgba(102, 102, 102, 0.95);
          filter: alpha(opacity=95) \9;
          text-align: center;
          display: flex;
          justify-content: center;
          align-items: center;
          .void_text {
            margin: 50px 0 16px;
            font-size: 18px;
            color: #fff;
            line-height: 1;
          }
          .btn-refresh {
            display: inline-block;
            padding: 0 20px;
            height: 32px;
            line-height: 32px;
            background: #ff9913;
            border-radius: 60px;
            font-size: 14px;
            color: #fff;
          }
          &.fix {
            margin-left: -79px !important;
            .void_text {
              font-size: 14px !important;
              margin: 0 15px !important;
            }
            .btn-refresh {
              margin-top: 16px !important;
            }
          }
        }
      }
    }
    .er_text {
      margin-top: 25px;
      text-align: center;
      font-size: 14px;
      color: #333;
      a {
        padding: 0 5px;
        color: #2577e3;
      }
    }
  }
}
</style>